import * as echarts from 'echarts'
const colorTable = [
  ['#f60404', '#cd060e', '#a50a11', '#7e0d11', '#590d0d'],
  ['#d6bdf3', '#c89df5', '#bb7cf5', '#ad58f3', '#a026ef']
]
const colors = []
function initColors() {
  for (let i = 0; i < colorTable.length; i++) {
    const linearColors = []
    for (let j = 0; j < colorTable[i].length; j++) {
      linearColors.push({
        offset: j / colorTable[i].length,
        color: colorTable[i][j]
      })
    }
    colors.push(new echarts.graphic.LinearGradient(0, 0, 1, 1, linearColors))
  }
}
initColors()
function getColor(index) {
  return colors[index % colors.length]
}
const singleColor = [
  '#FFAB91',
  '#FD7347',
  '#f60404',
  '#590d0d',
  '#4a4e5a',
  '#1e2d50',
  '#7a808c',
  '#cdf0b4',
  '#42d9f3',
  '#4f79d9'
]
function getSingleColor(index) {
  return singleColor[index % singleColor.length]
}

export { getColor, getSingleColor }
